package com.greensam.pixelengine.pojo.emuns;

import com.greensam.pixelengine.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 时间维度枚举
 *
 * @author Macro_Ray
 * @since 2025/7/08 17:22
 */
@Getter
@AllArgsConstructor
public enum TimeDimensionEnum {

    SECONDS(0, "seconds"),
    MINUTES(1, "minutes"),
    HOURS(2, "hours"),
    DAY(3, "day"),
    WEEK(4, "week"),
    MONTH(5, "month"),
    YEAR(6, "year"),

    ;

    private final Integer value;
    private final String description;


    /**
     * 根据 value 获取枚举
     */
    public static TimeDimensionEnum getEnumByValue(Integer value) {
        for (TimeDimensionEnum status : values()) {
            if (status.value.equals(value)) {
                return status;
            }
        }
        throw new BusinessException(ErrorCodeEnum.DataNotExist, "Invalid value: " + value);
    }
}
